package test00.lx04;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author CSY
 * @date 2025 - 04 - 02
 */
public class MainTest01 {
    public static void main(String[] args) {
        Student[] stus = {
            new Student("张三",18),
            new Student("李四",16),
            new Student("王五",21),
            new Student("赵六",20),
            new Student("小七",14),
        };
        Arrays.sort(stus, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                /*for (Student stu : stus) {
                    System.out.println(stu.getName() + "-" + stu.getAge());
                }
                System.out.println("o1:"+o1);
                System.out.println("o2:"+o2);
                System.out.println(o2.getAge() - o1.getAge());*/
                return o2.getAge() - o1.getAge();
            }
        });
        for (Student stu : stus) {
            System.out.println(stu.getName() + "-" + stu.getAge());
        }
    }
}
